using Common.Communal;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Product.API.Write.Applications.Commands.ProductProcess;

namespace Product.API.Write.Controllers
{
    /// <summary>
    /// 产品工艺API-写
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ProductProcessController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public ProductProcessController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 产品工艺添加
        /// </summary>
        /// <param name="command">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost("CreateProductProcess")]
        public async Task<ApiResult<int>> CreateProductProcess(CreateProductProcessCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 产品工艺修改
        /// </summary>
        /// <param name="command">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost("UpdateProductProcess")]
        public async Task<ApiResult<int>> UpdateProductProcess(UpdateProductProcessCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 产品工艺删除
        /// </summary>
        /// <param name="Id">主键</param>
        /// <returns>返回任务</returns>
        [HttpGet("DeleteProductProcess")]
        public async Task<ApiResult<int>> DeleteProductProcess(int Id)
        {
            DeleteProductProcessCommand command = new DeleteProductProcessCommand();
            command.Id = Id;
            return await mediator.Send(command);
        }

        /// <summary>
        /// 产品工艺批量添加
        /// </summary>
        /// <param name="command">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost("BatchProductProcess")]
        public async Task<ApiResult<int>> BatchProductProcess(BatchProductProcessCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 产品工艺批量修改
        /// </summary>
        /// <param name="command">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost("BatchUpdateProductProcess")]
        public async Task<ApiResult<int>> BatchUpdateProductProcess(BatchUpdateProductProcessCommand command)
        {
            return await mediator.Send(command);
        }

    }
}


